package com.antgroup.seckill.business.common.config;

import com.antgroup.seckill.business.goods.model.User;

/**
 * 用户信息上下文
 *
 * @author wangxy
 * @date 2024/8/6 18:20
 */
public class UserContext {

    private static ThreadLocal<User> userThreadLocal = new ThreadLocal<>();

    public static void setUser(User user) {
        userThreadLocal.set(user);
    }

    public static User getUser() {
        return userThreadLocal.get();
    }

    public static void clear() {
        userThreadLocal.remove();
    }
}
